<?php
namespace app\models;

use yii\base\Model;
use yii\web\UploadedFile;

/**
 * UploadForm is the model behind the upload form.
 */
class RaisedUploadForm extends Model
{
    /**
     * @var UploadedFile file hw_api_attribute()
     */
    public $projectPlan;
    public $applicationForm;
    public $attachment1;
    public $attachment2;
    public $attachment3;
    public $businessLicense;
    public $externalImage;
    public $insideImage;
    /**
     * @return array the validation rules.
     */
    public function rules()
    {   
        return [
            [['projectPlan'], 'file', 'extensions' => 'doc, docx'],
            [['applicationForm'],'file', 'extensions' => 'doc, docx'],
            [['attachment1'],'file', 'extensions' => 'doc, docx'],
            [['attachment2'],'file', 'extensions' => 'doc, docx'],
            [['attachment3'],'file', 'extensions' => 'doc, docx'],
            [['businessLicense'],'file', 'extensions' => 'jpg'],
            [['externalImage'],'file', 'extensions' => 'jpg'],
            [['insideImage'],'file', 'extensions' => 'jpg']
        ];
    }

    // public function upload()
    // {
    //     if ($this->validate()) {
    //     if(null != $this->projectPlan)
    //             $this->projectPlan->saveAs('uploads/' . $_COOKIE["user_id"] . 'projectPlan' . '.' . $this->projectPlan->extension);
    //     if(null != $this->applicationForm)
    //         $this->applicationForm->saveAs('uploads/' . $_COOKIE["user_id"] . 'applicationForm' . '.' . $this->applicationForm->extension);
    //     if(null != $this->attachment1)
    //         $this->attachment1->saveAs('uploads/' . $_COOKIE["user_id"] . 'attachment1' . '.' . $this->attachment1->extension);
    //     if(null != $this->attachment2)
    //         $this->attachment2->saveAs('uploads/' . $_COOKIE["user_id"] . 'attachment2' . '.' . $this->attachment2->extension);
    //     if(null != $this->attachment3)
    //         $this->attachment3->saveAs('uploads/' . $_COOKIE["user_id"] . 'attachment3' . '.' . $this->attachment3->extension);
    //     if(null != $this->businessLicense)
    //         $this->businessLicense->saveAs('uploads/' . $_COOKIE["user_id"] . 'businessLicense' . '.' . $this->businessLicense->extension);
    //     if(null != $this->externalImage)
    //         $this->externalImage->saveAs('uploads/' . $_COOKIE["user_id"] . 'externalImage' . '.' . $this->externalImage->extension);
    //     if(null != $this->insideImage)
    //         $this->insideImage->saveAs('uploads/' . $_COOKIE["user_id"] . 'insideImage' . '.' . $this->insideImage->extension);
    //         return true;
    //     } else {
    //         return false;
    //     }
    // }
}